<template>
	<view>
		<!-- 导航栏 -->
		<view class="head_box active">
			<cu-custom :isBack="true">
				<block slot="content">
					<text class="nav-title shopro-selector-rect">我的好友</text>
				</block>
			</cu-custom>
		</view><strong></strong>
		<view class="content_box" style="margin-top: -4rpx;overflow: hidden;">
			<scroll-view class="scroll-box" scroll-y scroll-with-animation enable-back-to-top>
				<view class="friend-list" v-for="(item, i) in list" :key="i">
					<view class="fline">
						<view class="photo">
							<view class="profile">
								<image :src="item.avatar" class="header_img" mode=""></image>
							</view>
							<view class="user-name">{{item.nickname}}</view>
						</view>
						<span class="date">{{item.createtime}}</span>
					</view>
				</view>
				<!-- 空白页 -->
				<shopro-empty v-if="!list.length && !isLoading" :emptyData="emptyData"></shopro-empty>
				<!-- 加载更多 -->
				<u-loadmore v-if="goodsList.length" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
				
				<!-- load -->
				<shopro-load v-model="isLoading"></shopro-load>
				
			</scroll-view>
		</view>
		<!-- 登录提示 -->
		<shopro-login-modal></shopro-login-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				emptyData: {
					img: this.$IMG_URL + '/imgs/empty/empty_goods.png',
					tip: '暂无数据~'
				},
				list: [],
				listParams: {
					page: 1
				},
				isLoading: true, //loading和空白页。
				loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
				lastPage: 1
			}
		},
		// 触底加载更多
		onReachBottom() {
			if (this.listParams.page < this.lastPage) {
				this.listParams.page += 1;
				this.getList();
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			getList(id) {
				let that = this
				that.isLoading = true;
				that.loadStatus = 'loading';
				that.$apiBase('myFriends').then(res => {
					if (res.code === 1) {
						that.isLoading = false;
						that.list = res.data.data
						console.log(that.list)
						that.lastPage = res.data.last_page;
						if (that.listParams.page < res.data.last_page) {
							that.loadStatus = 'loadmore';
						} else {
							that.loadStatus = 'nomore';
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.head_box{
	background: #FF8E00;
	.nav-title{
		color: #000;
	}
}
.friend-list {
    box-sizing: border-box;
    padding:0 30rpx;
    .fline {
        display: flex;
        height: 127rpx;
        justify-content: space-between;
        align-items: center; 
        border-bottom: 1rpx solid #BFBFBF;
        .photo {
            display: flex;
            justify-content: flex-start;
            align-items: center;
            width: 75%;
            .profile {
                width: 90rpx;
                height: 90rpx;
                margin-right: 30rpx;
                .header_img {
                    width: 90rpx;
                    height: 90rpx;
                    border-radius: 50rpx;
                }
            }
            .user-name{
                color: #333333;
                font-size: 30rpx; 
                font-weight: bold;
                overflow: hidden;
                text-overflow: ellipsis; 
                white-space: nowrap;
            }
        }
        .date {
            color: #999999;
            font-size: 28rpx; 
            font-weight: 500;
        }
    }     
}
</style>
